﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DockSample
{
    public class Method
    {
        private string accessModifier;
        private string returnType;
        private string methodName;
        private string parameterList;
        private string description;
        public string id;
        private List<NonFunctionRequirment> methodNFRList = new List<NonFunctionRequirment>();

        //
        public Method parentMethod;
        public string parentMethodId;
        public OriginalDiagram assoInfo;
        public string assoInfoId;

        public bool isComplex = false;

        public List<NonFunctionRequirment> MethodNFRList
        {
            get { return methodNFRList; }
            set { methodNFRList = value; }
        }
        //************************************************************************************
        public Method(string accessModifier, string returnType, string methodName, string parameterList, string description = "")
        {


            this.accessModifier = accessModifier;
            this.returnType = returnType;
            this.methodName = methodName;
            this.parameterList = parameterList;
            this.description = description;
            this.id = System.Guid.NewGuid().ToString();
        }

        public Method(string accessModifier, string returnType, string methodName, string parameterList, string id, string description = "")
        {
            this.accessModifier = accessModifier;
            this.returnType = returnType;
            this.methodName = methodName;
            this.parameterList = parameterList;
            this.description = description;
            this.id = id;
        }

        public string AccessModifier
        {
            get { return accessModifier; }
            set { accessModifier = value; }
        }
        public string ReturnType
        {
            get { return returnType; }
            set { returnType = value; }
        }
        public string MethodName
        {
            get { return methodName; }
            set { methodName = value; }
        }
        public string ParameterList
        {
            get { return parameterList; }
            set { parameterList = value; }
        }
        public string Description
        {
            get { return description; }
            set { description = value; }
        }
        public override string ToString()
        {
            if (parentMethod != null)
            {
                return parentMethod.methodName + "  " + accessModifier + "  " + returnType + "  " + methodName + "(" + parameterList + ");" + "  " + description;//两空格分开
            }
            else
            {
                return accessModifier + "  " + returnType + "  " + methodName + "(" + parameterList + ");" + "  " + description;
            }
        }
        public string getShowString()
        {
            string showStr = "";
            switch (accessModifier)
            {
                case "public":
                    showStr = "+";
                    break;
                case "private":
                    showStr = "-";
                    break;
                case "protected":
                    showStr = "#";
                    break;
                default:
                    showStr = "";
                    break;
            }
            return showStr + "  " + returnType + "  " + methodName + "()";
        }
    }
}
